package com.freecloud.whispered.auth.repository;

import com.freecloud.framework.repository.BaseDao;
import com.freecloud.whispered.auth.entity.SysRoleMenuEntity;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 角色与菜单对应关系
 * 
 * @author maomao
 * @email 138383877@qq.com
 */
@Repository
public interface SysRoleMenuDao extends BaseDao<SysRoleMenuEntity,Long> {
	
	/**
	 * 根据角色ID，获取菜单ID列表
	 */
	@Query(value = "select menu_id from sys_role_menu where role_id = :roleId",nativeQuery = true)
	List<Long> queryMenuIdList(@Param("roleId") Long roleId);

	/**
	 * 根据角色ID删除角色与菜单关系
	 * @param roleId
	 * @return
	 */
	int deleteByRoleId(Long roleId);
}
